package crm.view.statistic;

import java.awt.Component;

import javax.swing.JLabel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTree;
import javax.swing.tree.DefaultTreeCellRenderer;

import crm.model.teacherPC.Manager;
import crm.model.teacherPC.net.StudentPC;
import crm.model.teacherPC.statistic.Statistic;

public class StatisticTreeRender extends DefaultTreeCellRenderer{
	Manager manager;
	StatisticTreeRender(Manager manager){
		this.manager=manager;
	}

	@Override
	public Component getTreeCellRendererComponent(JTree tree, Object val,
			boolean sel, boolean expanded, boolean leaf, int row, boolean arg6) {

		JLabel lab = (JLabel)super.getTreeCellRendererComponent(tree, val, sel, expanded, leaf, row, arg6);

		if (val instanceof Statistic){
			StatisticTable tableModel = new StatisticTable((Statistic)val);
			JTable table = new JTable(tableModel);
			return new JScrollPane(new JTable(tableModel));
		}else if (val instanceof StudentPC){
			StudentPC student = (StudentPC) val;
			lab.setText(student.getUser());
			return lab;
		}else if (val instanceof Manager){
			lab.setText("Statistic");
			return lab;
		}else {
			return lab;
		}
	}

}
